<%--
  Created by IntelliJ IDEA.
  User: 33503
  Date: 2023/11/22
  Time: 17:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>注册</title>
    <!--引入jquery和bootstrap -->
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
</head>
<body style="background-size:cover;background-repeat: no-repeat; background-image: url('image/login.png'); position: relative">
<div style="background-color: #337ab7; color: white; width: 40%; height: 78%; float: right;
margin-right: 50px; margin-top: 100px;  border-radius: 10px; position: fixed;right:10px">
    <div align="center" style="padding-top: 2em">
        <span style="font-size: 3em">学生注册</span>
        <div><a href="${ pageContext.request.contextPath }/logout" style="color: whitesmoke">返回登录</a></div>
        ——————————————————————
        <form action="${pageContext.request.contextPath }/register" method="post" id="registerForm">
            <table style="padding-left: 1em; font-size: larger; color: white">
                <tr>
                    <td style="color: red; font-size: 20px" colspan="2">${wrongMsg}</td>
                </tr>
                <tr>
                    <td>学&nbsp;&nbsp;&nbsp;号：</td>
                    <td><input type=text name="s_id" id="s_id" placeholder="请输入学号"
                               style="width: 180px; height: 36px" onkeyup="value=value.replace(/[^\d]/g,'')"
                               maxlength=9/>
                    </td>
                </tr>
                <tr>
                    <td>姓&nbsp;&nbsp;&nbsp;名：</td>
                    <td><input type="text" name="s_name" id="s_name" placeholder="请输入姓名"
                               style="width: 180px; height: 36px"/>
                    </td>
                </tr>
                <tr>
                    <td>学&nbsp;&nbsp;&nbsp;院：</td>
                    <td><input type="text" name="college" id="college" placeholder="请输入学院"
                               style="width: 180px; height: 36px"/>
                    </td>
                </tr>
                <tr>
                    <td>班&nbsp;&nbsp;&nbsp;级：</td>
                    <td><input type="text" name="s_class" id="s_class" placeholder="请输入班级"
                               style="width: 180px; height: 36px" />
                    </td>
                </tr>
                <tr>
                    <td>联系方式：</td>
                    <td><input type="text" name="s_phone" id="s_phone" placeholder="请输入联系方式"
                               style="width: 180px; height: 36px" onkeyup="value=value.replace(/[^\d]/g,'')"
                               maxlength=11/>
                    </td>
                </tr>
                <tr>
                    <td>密&nbsp;&nbsp;&nbsp;码：</td>
                    <td><input type="password" name="s_pwd" id="s_pwd" placeholder="请输入密码"
                               style="width: 180px; height: 36px"/>
                    </td>
                </tr>
            </table>
            <br>
            <input type="button" value="注册"
                   style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; font-size: large; color: white; margin-right: 30px;"
                   onclick="zhuce()"/>
            <input type="reset" value="重置"
                   style="height: 30px; width: 60px; background-color: #2e6da4; border-color: #2e6da4; font-size: large; color: white;  margin-left: 50px;"/>
        </form>
    </div>
</div>
<script>
    function myTrim(x) {
        return x.replace(/^\s+|\s+$/gm, '');
    }
    function zhuce() {
        //提交form表单前判断
        var s_id = myTrim($("#s_id").val());//消除空格
        var s_name = myTrim($("#s_name").val());
        var college = myTrim($("#college").val());//消除空格
        var s_class = myTrim($("#s_class").val());
        var s_phone = myTrim($("#s_phone").val());//消除空格
        var s_pwd = myTrim($("#s_pwd").val());
        if (s_id === "" || s_id == null) {
            alert("学号不能为空");
            return;
        } else if (s_name === "" || s_name == null) {
            alert("姓名不可为空");
            return;
        } else if (college === "" || college == null) {
            alert("学院不可为空");
            return;
        } else if (s_class === "" || s_class == null) {
            alert("班级不可为空");
            return;
        } else if (s_phone === "" || s_phone == null) {
            alert("联系方式不可为空");
            return;
        } else if (s_pwd === "" || s_pwd == null) {
            alert("密码不可为空");
            return;
        } else {
            //试题类型为单选题或多选题时，CD选项不可为空
            $("#registerForm").submit();
            alert("验证中***验证成功将前往登录页面！")
            return false;
        }
    }
</script>
</body>
</html>